package com.ln.cmsln.controller.zlxl;


import com.alibaba.fastjson.JSON;
import com.ln.cmsln.mapper.ExaminationconditionMapper;
import com.ln.cmsln.pojo.entity.Examinationcondition;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wuwenzhe
 * @since 2022-03-31
 */
@CrossOrigin//跨域
@RestController
@RequestMapping("/examinationcondition")
public class ExaminationconditionController {

    @Resource
    private ExaminationconditionMapper examinationconditionMapper ;
    @RequestMapping("getAll")
    public String getAll(Integer page,Integer limit){
//        PageHelper.startPage(page,limit);
        List<Examinationcondition> examinationconditions = examinationconditionMapper.selectList(null);
        int count = examinationconditions.size();

        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("msg","");
        map.put("count",count);
        map.put("data",examinationconditions);

        String json = JSON.toJSONString(map);
        System.out.println("json = " + json);
        return json ;
    }
    @RequestMapping("delete")
    public String delete(@Param("id") Integer id) {
        System.out.println("id = " + id);
        int res = examinationconditionMapper.deleteById(id) ;
        String json = JSON.toJSONString(res);
        return json ;
    }
    @RequestMapping("add")
    public String add(Examinationcondition examinationcondition){
        System.out.println("examinationcondition = " + examinationcondition);
        int res = examinationconditionMapper.insert(examinationcondition);
        String json = JSON.toJSONString(res);
        return json ;
    }

}

